import QtQuick 2.15

SettingForm {
    state: "buttonStartEnable"

    buttonStart.onReleased: {
        applicationFlow.settedHour = tumblerHour.currentItem.text
        applicationFlow.settedMinute = tumblerMinute.currentItem.text
        applicationFlow.settedSecond = (parseInt(tumblerSecond.currentItem.text)).toString()
        applicationFlow.settingStart()
        applicationFlow.state = "Counting"
    }

    tumblerHour.onCurrentItemChanged: {
        if(("00"===tumblerHour.currentItem.text)&&("00"===tumblerMinute.currentItem.text)&&("00"===tumblerSecond.currentItem.text)){
            state = "buttonStartDisable"}
       else {
            state = "buttonStartEnable"
       }
    }

    tumblerMinute.onCurrentItemChanged: {
        if(("00"===tumblerHour.currentItem.text)&&("00"===tumblerMinute.currentItem.text)&&("00"===tumblerSecond.currentItem.text)){
             state = "buttonStartDisable"}
        else {
             state = "buttonStartEnable"
        }
    }

    tumblerSecond.onCurrentItemChanged: {
        if(("00"===tumblerHour.currentItem.text)&&("00"===tumblerMinute.currentItem.text)&&("00"===tumblerSecond.currentItem.text)){
             state = "buttonStartDisable"}
        else {
             state = "buttonStartEnable"
        }
    }

    Component.onCompleted: {
        if(("00"===tumblerHour.currentItem.text)&&("00"===tumblerMinute.currentItem.text)&&("00"===tumblerSecond.currentItem.text)){
             state = "buttonStartDisable"}
        else {
             state = "buttonStartEnable"
        }
    }

    states: [
        State {
            name: "buttonStartEnable"
            PropertyChanges {
                target: buttonStart
                enabled: true
            }
        },
        State {
            name: "buttonStartDisable"
            PropertyChanges {
                target: buttonStart
                enabled: false
            }
        }
    ]

}
